[19.0][IMP] fs_attachments: fix parsing of stored filenames when storing locally - #638
[19.0][IMP] fs_attachments: fix parsing of stored filenames when storing locally#638CRogos wants to merge 1 commit into
Conversation
|
Hi @lmignon, |
40d07a9 to
e71df9a
Compare
e71df9a to
9083b3f
Compare
|
@CRogos Can you explain your use case? I can't imagine the context in which you're encountering this problem. How can I reproduce your issue? |
|
The error occurred when trying to post an expense in our staging system. Because we don't want that any attachment of the production system is deleted by accident from the staging server, we replace the read/write credentials with with readonly credentials by an neutralize.sql script. We also deactivate that new attachments are uploaded to the cloud storage from the staging system, by removing all models from the fs.storage setting. Instead they are stored the usual odoo.sh way on the server. All attachments which were copied from the production system are still accessible by the readonly connection. So the error occurs when the module is installed, but the new attachment is not stored in the cloud instead on the native story. |
|
@CRogos IMO, the issue you're experiencing comes from the way the library is being used and how your staging process is managed. We have never encountered this problem because our approach is different. With your current approach, you can end up with records whose data is inconsistent with the storage configuration. If I understand your explanation correctly, you're mixing records from different storages that are associated with the same storage configuration. A safer approach for a staging environment is to add a dedicated storage backend and configure it as the default for attachments (https://github.com/OCA/storage/tree/18.0/fs_attachment#tips--tricks). At the same time, you can configure the production storage to use a read-only user. This avoids inconsistencies while still allowing you to work safely with production data. |
No, I actually only disable all configurations from write access by removing all models from the configuration and changing the credentials with read only access. Could it be, that there is no "://" in the file path by odoo default, and therefore _fs_parse_store_fname is called without "://" in the url? I agree that when creating an explicit file default configuration for the staging system, the url would look something like this "local-file://..." and therefore the error should not occur, but I think the module should not crash, if the odoo native format is used, instead it should behave like odoo native. |
|
In your stack_trace, the error occurs into the method compute of the fs_url. Nevertheless this compute only occurs if your attachment has a fs_filename and the fs_filename should only be filled if the attachment is stored into a configured fs_storage 🤔 .... |
|
The method |
|
I think this ir_attachment is not connected to any fs_storage. |
In such a case, |
|
I agree... I assume _compute_fs_url is called for new record. storage/fs_attachment/models/ir_attachment.py Lines 108 to 119 in af1a3be |
|
@CRogos The guard is |
|
Not sure if this is the case here, but we should also consider this scenario: |
In such a case, the attachment is linked to a storage. If the configuration is stored on the record, then the record is linked to a storage. But once again, we already have a guard with |




Solves this error when new attachments should be stored locally: